home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.2 Applications 1996 May
/
SGI IRIX 6.2 Applications 1996 May.iso
/
dist
/
impr_dev.idb
/
usr
/
include
/
stiff.h.z
/
stiff.h
Wrap
C/C++ Source or Header
|
1996-05-06
|
13KB
|
385 lines
/**************************************************************************
*
* Copyright (c) 1992 Silicon Graphics, Inc.
* All Rights Reserved
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
*
* The copyright notice above does not evidence any actual of intended
* publication of such source code, and is an unpublished work by Silicon
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is
* the property of Silicon Graphics, Inc. Any use, duplication or
* disclosure not specifically authorized by Silicon Graphics is strictly
* prohibited.
*
* RESTRICTED RIGHTS LEGEND:
*
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
* Technical Data and Computer Software clause at DFARS 52.227-7013,
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR
* Supplement. Unpublished - rights reserved under the Copyright Laws of
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N.
* Shoreline Blvd., Mountain View, CA 94039-7311
**************************************************************************
*
* File: stiff.h
*
* Description:
*
* Stream TIFF API dealing with TIFF files which are streams (ie, the
* can be accessed without seeking.
*
* The criteria which a stream TIFF file must meet (in addition to
* being a valide TIFF file):
*
* 1. The images in a stiff file must be in page number order
*
* 2. Any data which does not fit in the value section of a tag must
* be located immediately after the IFD, must occur in the same
* order in which the tags are encountered. The exception to this
* rule is the image data itself, which must come last for each
* image.
*
* 3. Image data must immediately follow the IFD and any offset values
* associated with it.
*
* 4. A terminating IFD will always be added to the STIFF file. This
* IFD guarantees that an IFD with 0000 in its 'next IFD' field
* will appear in the IFD chain. Note that this IFD will not be
* encountered when following IFD pointers if the last 'real' IFD
* is written with the 'last' parameter set to 1 in STWriteImageHeader.
*
* Graphically, a STIFF file looks like this:
*
* +------------------------------+
* | TIFF header (8 bytes) |
* +------------------------------+
* | optional intervening space |
* +------------------------------+
* | IFD for page 1 |
* +------------------------------+
* | Data for long values in IFD1 |
* +------------------------------+
* | Image data for page 1 |
* +------------------------------+
* | optional intervening space |
* +------------------------------+
* | IFD for page 2 |
* +------------------------------+
* | Data for long values in IFD2 |
* +------------------------------+
* | Image data for page 2 |
* +------------------------------+
* | .... |
* +------------------------------+
* | Terminating emtpy IFD |
* +------------------------------+
*
* With these restrictions in mind, this implementation supports
* motorola byte ordering class B, G, and R TIFF data, as well as
* some new classes:
*
* Class CMY:
* ----------
* Class CMY stiff data is in Cyan, Magenta, Yellow format. A new
* value for the PhotometricInterpret tag (5), is used to
* differentiate this from RGB data. BitsPerSample values of 1,1,1,
* 4,4,4 and 8,8,8 are supported.
*
* Tag Possible values
* -----------------------------------------------------
* BitsPerSample (1,1,1), (4,4,4), (8,8,8)
* PhotoMetricInterpret 5
* SamplesPerPixel 3
* PlanarConfiguration 1,2
*
* For BitsPerSample values of (1,1,1) and PlanarConfiguration value
* of 1, pixels are stored 2 to a byte, with the bits in the byte
* from most to least significant as follows: CMY0CMY0. Rows are
* padded to contain an integral number of bytes.
*
* This implementation also supports Class R data with BitsPerSample
* values of (1,1,1), with data layed out similarly.
*
* Class CMYK:
* -----------
* Class CMYK stiff data is in Cyan, Magenta, Yellow, Black format.
* The value of the PhotoMetricInterp tag for such data is 5.
* BitsPerSample values of 1,1,1,1, 4,4,4,4 and 8,8,8,8 are supported.
*
* Tag Possible values
* -----------------------------------------------------
* BitsPerSample (1,1,1,1), (4,4,4,4), (8,8,8,8)
* PhotoMetricInterpret 5
* SamplesPerPixel 4
* PlanarConfiguration 1,2
*
* For BitsPerSample values of (1,1,1,1) and PlanarConfiguration
* value of 1, pixels are stored 2 to a byte, with the bits in the
* byte from most significant to least significant as follows:
* CMYKCMYK. Rows are padded to contain an integral number of
* bytes.
*
* This API insulates the user from having to actually deal with tags;
* data structures are passed to functions such as STWriteImageHeader()
* which convert the provided information into tag format and write it
* to the stream.
*
* Full access to tags is provided, however, via the STAddTag() and
* STRemoveTag() functions. It should be possible to write a STIFF
* file without having to know anything about TIFF itself, unless
* these functions are used.
*
**************************************************************************/
#ident "$Revision: 1.25 $"
#ifndef _ST_STIFF_H
#define _ST_STIFF_H
/*
* Stream TIFF tags (TIFF tags + SGI specific tags)
*/
/* --- BEGIN TAGS --- Do not alter or move this line */
#define STNewSubfileType 0xfe
#define STSubfileType 0xff
#define STImageWidth 0x100
#define STImageLength 0x101
#define STBitsPerSample 0x102
#define STCompression 0x103
#define STPhotometricInterpretation 0x106
#define STThresholding 0x107
#define STCellWidth 0x108
#define STCellLength 0x109
#define STFillOrder 0x10a
#define STDocumentName 0x10d
#define STImageDescription 0x10e
#define STMake 0x10f
#define STModel 0x110
#define STStripOffsets 0x111
#define STOrientation 0x112
#define STSamplesPerPixel 0x115
#define STRowsPerStrip 0x116
#define STStripByteCounts 0x117
#define STMinSampleValue 0x118
#define STMaxSampleValue 0x119
#define STXResolution 0x11a
#define STYResolution 0x11b
#define STPlanarConfiguration 0x11c
#define STPageName 0x11d
#define STXPosition 0x11e
#define STYPosition 0x11f
#define STFreeOffsets 0x120
#define STFreeByteCounts 0x121
#define STGrayResponseUnit 0x122
#define STGrayResponseCurve 0x123
#define STGroup3Options 0x124
#define STGroup4Options 0x125
#define STResolutionUnit 0x128
#define STPageNumber 0x129
#define STColorResponseCurves 0x12d
#define STSoftware 0x131
#define STDateTime 0x132
#define STArtist 0x13b
#define STHostComputer 0x13c
#define STPredictor 0x13d
#define STWhitePoint 0x13e
#define STPrimaryChromaticities 0x13f
#define STColorMap 0x140
#define STHalftoneHints 0x141
#define STTileWidth 0x142
#define STTileLength 0x143
#define STTileOffsets 0x144
#define STTileByteCounts 0x145
#define STInkSet 0x14c
#define STInkNames 0x14d
#define STNumberOfInks 0x14e
#define STDotRange 0x150
#define STTargetPrinter 0x151
#define STExtraSamples 0x152
#define STSampleFormat 0x153
#define STSMinSampleValue 0x154
#define STSMaxSampleValue 0x155
#define STTransferRange 0x156
#define STJPEGProc 0x200
#define STJPEGInterchangeFormat 0x201
#define STJPEGInterchangeFormatLength 0x202
#define STJPEGRestartInterval 0x203
#define STJPEGLosslessPredictors 0x205
#define STJPEGPointTransforms 0x206
#define STJPEGQTables 0x207
#define STJPEGDCTables 0x208
#define STJPEGACTables 0x209
#define STYCbCrCoefficients 0x211
#define STYCbCrSubSampling 0x212
#define STYCbCrPositioning 0x213
#define STReferenceBlackWhite 0x214
#define STSGIPrivate32995 0x80e3 /* In use by Image Library */
#define STSGIPrivate32996 0x80e4 /* In use by Image Library */
#define STSGIPrivate32997 0x80e5 /* In use by Image Library */
#define STSGIPrivate32998 0x80e6 /* In use by Image Library */
#define STSGIPrivate32999 0x80e7 /* In use by Image Library */
#define STCopyright 0x8298
#define STSGIPrinting 0x862f /* In use by Impressario */
#define STSGIPrivate34352 0x8630
#define STSGIPrivate34353 0x8631
#define STSGIPrivate34354 0x8632
#define STSGIPrivate34355 0x8633
/* --- END TAGS --- Do not alter or move this line */
/*
* Error numbers indicating reasons for failure of libstiff functions. All
* libstiff functions set STerrno to one of these values when their return
* values indicate that a failure has occurred.
*/
#define STEBASE 200
#define STENOMEM (STEBASE)
#define STENOTFOUND (STEBASE + 1)
#define STEBADTAG (STEBASE + 2)
#define STEBADSTREAM (STEBASE + 3)
#define STENEEDSEEK (STEBASE + 4)
#define STEREADFROMWRITE (STEBASE + 5)
#define STEWRITETOREAD (STEBASE + 6)
#define STESYSCALL (STEBASE + 7)
#define STEBADIMAGE (STEBASE + 8)
#define STEEOF (STEBASE + 9)
#define STELAST STEEOF
#define ST_READ 0 /* open for reading */
#define ST_WRITE 1 /* open for writing */
#define ST_COMPAT 2 /* don't do anything that's not in TIFF spec */
/* (no SGI enhancements; attempts to do things */
/* requiring SGI enhancements return an error */
#define ST_INTEL 0x4949
#define ST_MOTOROLA 0x4d4d
#define ST_MAGIC 42
/* Photometric interpretation */
typedef unsigned short STType;
/*
* K, W, RGB, CMAP, MASK, and SEP all correspond to the tag values
* from the TIFF specification for the photometric interpretation tag.
*/
#define ST_TYPE_K 0 /* 1 == black, 0 == white */
#define ST_TYPE_W 1 /* 1 == white, 0 == black */
#define ST_TYPE_RGB 2 /* red, green, blue */
#define ST_TYPE_CMAP 3 /* color map */
#define ST_TYPE_MASK 4 /* transparency mask */
#define ST_TYPE_SEP 5 /* separated: cmyk or cmy */
/*
* These others are all obtained from IFDs in which the photometric
* interpretation tag is 5 (separation), and libstiff was able to
* decipher the ink names.
*/
#define ST_TYPE_YMC 0xff01 /* yellow, magenta, cyan */
#define ST_TYPE_YMCK 0xff02 /* yellow, magenta, cyan, black */
#define ST_TYPE_KCMY 0xff03 /* black, cyan, magenta, yellow */
#define ST_TYPE_CMY 0xff04 /* cyan, magenta, yellow */
#define ST_TYPE_CMYK 0xff05 /* cyan, magenta, yellow, black */
/* Planar Configuration */
typedef unsigned short STPlane;
#define ST_PLANE_PACKED 1 /* Chunky format */
#define ST_PLANE_PLANAR 2 /* Planar format */
/* Tag Types */
typedef unsigned short STTagType;
#define ST_TAG_TYPE_BYTE 1
#define ST_TAG_TYPE_ASCII 2
#define ST_TAG_TYPE_SHORT 3
#define ST_TAG_TYPE_LONG 4
#define ST_TAG_TYPE_RATIONAL 5
#define ST_TAG_TYPE_SBYTE 6
#define ST_TAG_TYPE_UNDEFINED 7
#define ST_TAG_TYPE_SSHORT 8
#define ST_TAG_TYPE_SLONG 9
#define ST_TAG_TYPE_SRATIONAL 10
#define ST_TAG_TYPE_FLOAT 11
#define ST_TAG_TYPE_DOUBLE 12
#define ST_LAST_TAG ST_TAG_TYPE_DOUBLE
typedef struct tag_sttag {
unsigned short tag;
unsigned short type;
unsigned long len;
void *val;
} STTag;
typedef struct tag_taglist {
STTag tag;
struct tag_taglist *next;
} STTagList;
typedef struct tag_stiff {
unsigned long offset, next;
int fd, page, flags;
STTagList *tags;
unsigned short byteOrder;
unsigned int canSeek : 1;
} STStream;
typedef struct tag_imghdr {
unsigned long width, height;
unsigned short bitsPerSample;
unsigned short samplesPerPixel;
unsigned long imgbytes;
STType type;
STPlane plane;
} STImageHeader;
typedef struct tag_tiffheader {
unsigned short byteOrder;
unsigned short magic;
unsigned long offset;
} STHeader;
/*
* set to an STE value upon error
*/
extern int STerrno;
#ifdef __cplusplus
extern "C" {
#endif
extern int STReadImageHeader(STStream *st, STImageHeader *hd);
extern int STWriteImageHeader(STStream *st, STImageHeader *hd, int last);
extern int STAddTag(STStream *st, unsigned short tag, STTagType type,
unsigned long len, void *val);
extern int STRemoveTag(STStream *st, unsigned short tag);
extern int STGetTag(STStream *st, unsigned short tag, STTagType *type,
unsigned long *len, void **val);
extern STStream* STOpen(int fd, int flags);
extern int STClose(STStream *st);
extern int STSkipTo(STStream *st, unsigned long offset);
extern int STRead(STStream *st, void *buf, int nbytes);
extern int STWrite(STStream *st, void *buf, int nbytes);
extern void STPerror(char *pre);
extern char* STErrorString(int err);
extern int STPrintTags(FILE *fp, STStream *st);
#ifdef __cplusplus
}
#endif
#endif /* _ST_STIFF_H */